<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.ccut.edu.cn/saturn" prefix="saturn"%>
<%@page import="edu.ccut.saturn.component.SaturnAuthorityManager"%>
<%@page import="java.util.List"%>
<%@page import="edu.ccut.saturn.component.IAuthorityResourceInfo"%>
<html>
<head>
<title>权限列表</title>
<%@ include file="/extjs/include/all.jsp" %>
</head>
<body>
<div id="resourceListForm" style="width:100%"></div>
<div id="result" style="width:100%"></div>
</body>
</html>
<script>
	
	var bundleStore = new Ext.data.JsonStore({
		url:'${pageContext.request.contextPath}/edu.ccut.saturn.authority.impl::/resourceModule/action/QueryBundleName.action',
	    root:'bundleList',
	    fields:  [
			{name:'key'},
			{name:'value'}
		]
	});
	bundleStore.load();
	var resourceListForm = new Ext.FormPanel({
		title:'按bundle查询资源列表',
		frame:true,
		collapsible:true,
		renderTo:'resourceListForm',
		bodyStyle:'padding:5px 5px 0',
		items:[{
		    layout:'column',
            items:[{
            	columnWidth:1,
		        layout: 'form',
	            items: [{
	               	xtype:'combo',
		            fieldLabel: 'bundle名',
		            width:350,
		            name: 'bundleName_show',
		            id:'bundleName_show',
		            store: bundleStore,
			        displayField:'value',
			        valueField :'key', 
			        hiddenName: 'bundleName' ,//真正传到后台的名称
			        typeAhead: true,
			        mode: 'local',
			        forceSelection: true,
			        triggerAction: 'all',
			        emptyText:'all bundles',
			        selectOnFocus:true,
			        editable: false
		    	}]
		    }]
         }],
         buttons:[{
         		text:'查询',
         		handler:function(){
					ds.load();
         		}	
         }]
	});
	
	         			
	var resultWidth = Ext.get('result').getWidth();

	var cm = new Ext.grid.ColumnModel([
		new Ext.grid.RowNumberer(),
		{header:'资源',dataIndex:'resourceKey',width:resultWidth*0.3,sortable:true},
		{header:'名称',dataIndex:'name',width:resultWidth*0.3,sortable:true},
		{header:'描述',dataIndex:'description',width:resultWidth*0.3,sortable:true}
	]);
	var ds = new Ext.data.JsonStore({
		url:'${pageContext.request.contextPath}/edu.ccut.saturn.authority.impl::/resourceModule/action/QueryBundleList.action',
		root:'resourceList',
		totalProperty:'count',
		 
	    fields:[
			{name:'resourceKey',mapping:'resourceKey'},
			{name:'name',mapping:'name'},
			{name:'description'}
		]
	});
	
	ds.load();
	
	ds.on('beforeload',function(){
		Ext.apply(
		    this.baseParams,
		      {
					bundleName:Ext.get("bundleName").dom.value
		      });
	    	}	
	);
	cm.defaultSortable = true; 
	    var grid = new Ext.grid.GridPanel({ 
	    el: 'result', 
	    title:'资源列表', 
	   	autoHeight:true, 
	   	bodyStyle:'width:100%',
	    stripeRows: true,
	    collapsible:true,
	    trackMouseOver:false, 
	    loadMask: {msg:'正在加载数据，请稍侯……'}, 
	    store:ds, 
	    cm: cm
	});
	grid.render();
	grid.getView().refresh();
</script>